package com.dove.entity.mapper;

import java.util.List;

import com.dove.entity.Users;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UsersMapper {

    @Insert(value = "insert into dove.users (name, phone, userid, cret_no, accessToken, credate, upddate) VALUES (#{users.name}, #{users.phone}, #{users.userid}, #{users.cret_no}, #{users.accessToken}, #{users.credate}, #{users.upddate});")
    int insert(@Param("users") Users users);

    @Update(value = "update dove.users u set u.name=#{users.name} where u.userid=#{users.userid};")
    int update(@Param("users") Users users);

    @Delete(value = "delete from dove.users where userid=#{userid};")
    int delete(String userid);

    /**
     * 查询 按照id查询
     * 
     * @param userid
     * @return
     */
    @Select(value = "select u.ids, u.name, u.phone, u.userid, u.cret_no, u.accessToken, u.credate, u.upddate from dove.users u where u.userid=#{userid};")
    List<Users> findByUserid(String userid);

}
